CREATE TABLE [dbo].[tb_TiposDeInstalaciones]
(
[idTipoDeInstalacion] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updateTipoInstalacion] ON [dbo].[tb_TiposDeInstalaciones] 
FOR UPDATE
AS
if (update(idTipoDeInstalacion)) begin
	UPDATE tb_Instalaciones
	SET TipoDeInstalacion = (SELECT idTipoDeInstalacion from inserted)
	WHERE TipoDeInstalacion in (SELECT idTipoDeInstalacion from deleted)
end
GO
ALTER TABLE [dbo].[tb_TiposDeInstalaciones] ADD CONSTRAINT [PK_tb_TiposDeInstalaciones] PRIMARY KEY NONCLUSTERED  ([idTipoDeInstalacion]) ON [PRIMARY]
GO
